package org.adempiere.apps.graph;

import java.awt.Color;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

import layout.TableLayout;

public class BSCTableHeaderPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1050010320374267842L;
	protected static String[] tableHeader = {"№","КПД","Ед. изм.","Вес %","План","Факт","Расчет показателя","Примечание","Ссылка на прикрепление","Статус"};
	protected static int[] cellWidth =      {30 ,300  ,80        ,80     ,80    ,80    ,300                 ,300         ,300                     ,80      , 0};
	protected static int[] cellHeight = {50,0};
	public static double[][] tableSize = null;
	
	private TableLayout tableLayout = null;
	
	public BSCTableHeaderPanel() {
		super();
		setBorder(BorderFactory.createLineBorder(Color.BLACK));
		tableLayout = new TableLayout(initTableSize(cellHeight)); 
		setLayout(tableLayout);
		initView();
	}
	
	private void initView() {
		for(int i = 0; i < tableHeader.length; i++) {
			String pos = Integer.toString(i)+",0";
			JLabel lbl = new JLabel("<html>"+tableHeader[i]+"</html>");
			lbl.setHorizontalAlignment(JLabel.CENTER);
			lbl.setBorder(getBorder());
			lbl.setFont(getHeaderTableFont());
			add(lbl,pos);
		}
	}
	
	/**
	 * 
	 */
	public static double[][] initTableSize(int[] height) {
		int size = tableHeader.length + 1;
		tableSize = new double[2][size];
		for(int i=0; i < size; i++) {
			tableSize[0][i] = ( i < cellWidth.length ? cellWidth[i] : 0);
			tableSize[1][i] = ( i == 0 ? height[0] : height[1]);
		}
		return tableSize;
	}	
	
	public static Font getHeaderTableFont() {
		return BSCCardPanelNew.getTotalFont();
	}
}
